package com.example.train.api.controller.v1;

import com.example.train.api.dto.EmployeeDTO;
import com.example.train.app.service.IndexService;
import com.example.train.domain.entity.Employee;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1")
public class IndexController {

    private final IndexService indexService;

    public IndexController(IndexService indexService) {
        this.indexService = indexService;
    }

    @GetMapping("/index")
    public ResponseEntity<?> index() {
        return ResponseEntity.ok("server is running.....");
    }

    @GetMapping("/status")
    public ResponseEntity<?> status() {
        String status = indexService.status();
        return ResponseEntity.ok(status);
    }

    @GetMapping("/list")
    public ResponseEntity<?> list(EmployeeDTO employeeDTO) {
        List<Employee> employeeList = indexService.listEmployees(employeeDTO);
        return ResponseEntity.ok(employeeList);
    }

}
